<?php defined('_JEXEC') or die('Restricted access');
	//include_once(JPATH_ROOT.DS.'administrator'.DS.'includes'.DS.'submenu.php');	 
?>
<?php JHTML::_('behavior.tooltip'); ?>
<?php
	// Set toolbar items for the page
	JToolBarHelper::title(   JText::_( 'Quản lý Kiểm định & nén tĩnh' ), 'generic.png' );
	JToolBarHelper::publishList();
	JToolBarHelper::unpublishList();
	JToolBarHelper::deleteList();
	JToolBarHelper::editListX();
	JToolBarHelper::addNewX();
	$ordering = ($this->lists['order'] == 'ordering');
?>
<form action="index.php" method="post" name="adminForm">
<table>
<tr>
	<td align="left" width="100%">
		<?php echo JText::_( 'Filter' ); ?>:
		<input type="text" name="search" id="search" value="<?php echo htmlspecialchars($this->lists['search']);?>" class="text_area" onchange="document.adminForm.submit();" />
		<button onclick="thiform.submit();"><?php echo JText::_( 'Go' ); ?></button>
		<button onclick="document.getElementById('search').value='';thiform.getElementById('filter_parent').value='0';thiform.getElementById('filter_state').value='';thiform.submit();"><?php echo JText::_( 'Reset' ); ?></button>
	</td>
	<td nowrap="nowrap">
		<?php
			echo $this->lists['state'];
		?>
	</td>
</tr>
</table>
<div id="editcell">
<table class="adminlist">
	<thead>
		<tr>
			<th width="5">
				<?php echo JText::_( 'NUM' ); ?>
			</th>
			<th width="20">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />
			</th>
			<th class="title">
				<?php echo JHTML::_('grid.sort',  'Title', 'name', $this->lists['order_Dir'], $this->lists['order'] ); ?>
			</th>
            <th width="10%">Tên file</th>
            <th width="10%">Thể loại</th>
			<th width="5%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort',  'Published', 'published', $this->lists['order_Dir'], $this->lists['order'] ); ?>
			</th>
			<th width="8%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort',  'Order', 'ordering', $this->lists['order_Dir'], $this->lists['order'] ); ?>
				<?php if ($ordering) echo JHTML::_('grid.order',  $this->items ); ?>
			</th>		
			<th width="1%" nowrap="nowrap">
				<?php echo JHTML::_('grid.sort',  'ID', 'id', $this->lists['order_Dir'], $this->lists['order'] ); ?>
			</th>
		</tr>
	</thead>
	<tfoot>
		<tr>
			<td colspan="9">
				<?php echo $this->pagination->getListFooter(); ?>
			</td>
		</tr>
	</tfoot>
	<tbody>
    <?php	
	$k = 0;
	for ($i=0, $n=count( $this->items ); $i < $n; $i++)
	{		
		$row = &$this->items[$i];	
		$link 	= JRoute::_( 'index.php?option=com_kdnt&view=detail&task=edit&cid[]='. $row->id );
		$checked 	= JHTML::_('grid.checkedout',   $row, $i );
		$published 	= JHTML::_('grid.published', $row, $i );
		$parent = $row->parent;
		/*$db=&JFactory::getDBO();
		$db->setQuery("select * from #__category where id = '$parent' ");
		$cat_title = $db->loadAssoc();*/
		
	?>
    <tr class="<?php echo "row$k"; ?>">
        <td>
            <?php echo $this->pagination->getRowOffset( $i ); ?>
        </td>
        <td>
            <?php echo $checked; ?>
        </td>
        <td align="left">
			<a href="<?php echo $link; ?>"><?php echo $row->name; ?></a>
        </td>
        <td align="center">
			<?php echo $row->image; ?>
        </td>
        <td align="center">
			<?php
				if($row->position == 'nt')
					echo 'Nén tĩnh';
				if($row->position == 'kd')
					echo 'Kiểm định';
			?>
        </td>
        <td align="center">
			<?php echo $published;?>
        </td>
        <td class="order">
        <span>
			<?php echo $this->pagination->orderUpIcon( $i, ($row->parent == @$this->items[$i-1]->parent),'orderup', 'Move Up', $ordering ); ?></span>
		<span>
			<?php echo $this->pagination->orderDownIcon( $i, $n, ($row->parent == @$this->items[$i+1]->parent), 'orderdown', 'Move Down', $ordering ); ?>
        </span>
			<?php $disabled = $ordering ?  '' : 'disabled="disabled"'; ?>
			<input type="text" name="ordering[]" size="5" value="<?php echo $row->ordering;?>" <?php echo $disabled ?> class="text_area" style="text-align: center" />        
			
        </td>        
        <td align="center">
			<?php echo $row->id; ?>
        </td>
    <?php } ?>
    </tbody>
</table>
</div>
	<input type="hidden" name="option" value="com_kdnt" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
	<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
</form>